package guijavacommander.tasks;

import guijavacommander.tasks.Task;
import guijavacommander.tasks.ProgressListener;

import javax.swing.*;
import java.awt.*;

/**
 * User: Deady
 * Date: 16.07.2009
 * Time: 12:03:41
 */
public class ThreadStatusDialog extends ThreadDialog implements ProgressListener {

    JProgressBar bar;

    public ThreadStatusDialog(Frame owner, Task task) throws HeadlessException {
        super(owner, task);
        init(task);
    }

    public ThreadStatusDialog(Dialog owner, Task task) throws HeadlessException {
        super(owner, task);
        init(task);
    }

    protected void init(Task task) {
        super.init(task);
        bar = new JProgressBar(task.getMin(), task.getMax());
        JPanel panel = new JPanel();
        panel.add(bar);
        getContentPane().add(panel, BorderLayout.SOUTH);
        task.addProgressListener(this);
        //pack();
    }



    public void progressUpdated(int currentProgress) {
        bar.setValue(currentProgress);
    }
}
